package com.yumi.controller;


import com.yumi.service.ZhuhaitongService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.yumi.common.Result;

@Tag(name = "交通数据接口", description = "交通数据处理相关接口")
@RestController
@Slf4j
@RequestMapping("/api")
@RequiredArgsConstructor
public class ZhuhaitongController {

    private final ZhuhaitongService zhuhaitongService;
    
    /**
     * 交通数据详情查询
     * @param file 数据文件
     * @param date 查询日期
     * @param isEncrypt 是否加密（接收字符串值）
     * @return 查询结果
     */
    @Operation(summary = "交通数据详情查询", description = "上传数据文件并查询指定日期的交通数据详情")
    @PostMapping("/trafficApi/getDetailInfo")
    public Result<?> getDetailInfo(
            @RequestParam("file") MultipartFile file,
            @RequestParam("date") String date,
            @RequestParam(value = "isEncrypt", required = false) String isEncrypt) {
            log.info("Received file: {}", file.getOriginalFilename());
            log.info("Date: {}", date);
            log.info("Is encrypt: {}", isEncrypt);
            zhuhaitongService.Download(file, date, isEncrypt);
            return Result.success();
    }
}